/*
 * consultarPersona2.java
 *
 * Created on 14-oct-2008, 8:39:16
 */
package investigaciones_itm.Personas;

import com.sun.rave.faces.data.DefaultSelectItemsArray;
import com.sun.webui.jsf.component.AddRemove;
import com.sun.webui.jsf.model.SingleSelectOptionsList;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Body;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.Head;
import com.sun.webui.jsf.component.Html;
import com.sun.webui.jsf.component.Label;
import com.sun.webui.jsf.component.Link;
import com.sun.webui.jsf.component.Page;
import com.sun.webui.jsf.component.PanelGroup;
import com.sun.webui.jsf.component.PanelLayout;
import com.sun.webui.jsf.component.Tab;
import com.sun.webui.jsf.component.TabSet;
import com.sun.webui.jsf.component.TextField;
import com.sun.webui.jsf.model.Option;
import itm.exception.ControlException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.FacesException;
import investigaciones_itm.RequestBean1;
import investigaciones_itm.ApplicationBean1;
import investigaciones_itm.SessionBean1;
import itm.bo.personas.PersonasBO;
import itm.vo.administracion.InstitucionVO;
import itm.vo.administracion.OcupacionesVO;
import itm.vo.administracion.RolVo;
import itm.vo.personas.GlobalPersonaTO;
import itm.vo.personas.PersonaOcupacionVO;
import itm.vo.personas.PersonaRolVO;
import itm.vo.personas.PersonaVO;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.faces.component.UISelectItems;
import javax.faces.component.html.HtmlMessages;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.component.html.HtmlSelectOneListbox;
import javax.faces.model.SelectItem;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 *
 * @author Administrador
 */
public class consultarPersona2 extends AbstractPageBean {

    private GlobalPersonaTO personaTO = new GlobalPersonaTO();
    private PersonaOcupacionVO pOcupacionVO = new PersonaOcupacionVO();
    private OcupacionesVO ocupacionVO = new OcupacionesVO();
    private InstitucionVO institucionVO = new InstitucionVO();
    private RolVo rolVO = new RolVo();
    private PersonaRolVO pRolVO = new PersonaRolVO();
    private DropDown dropDownOcupacion = new DropDown();
    private SingleSelectOptionsList optionsOcupacion = new SingleSelectOptionsList();
    private DropDown dropDownInstitucion = new DropDown();
    private SingleSelectOptionsList optionsInstitucion = new SingleSelectOptionsList();
    private List<OcupacionesVO> listaOcupacion = new ArrayList<OcupacionesVO>();
    private List<InstitucionVO> listaInstitucion = new ArrayList<InstitucionVO>();
    private List<RolVo> listaRol = new ArrayList<RolVo>();
    private PersonaVO personaVO = new PersonaVO();
    private PersonasBO personaBO;

    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
        cargarOcupacion();
        cargarInstitucion();
        dropDownEstadoDefaultOptions.setOptions(new com.sun.webui.jsf.model.Option[]{new com.sun.webui.jsf.model.Option("Activo", "Activo"), new com.sun.webui.jsf.model.Option("Inactivo", "Inactivo")});
        addRemoveList1.setWidth("383");
    }
    private Page page1 = new Page();

    public Page getPage1() {
        return page1;
    }

    public void setPage1(Page p) {
        this.page1 = p;
    }
    private Html html1 = new Html();

    public Html getHtml1() {
        return html1;
    }

    public void setHtml1(Html h) {
        this.html1 = h;
    }
    private Head head1 = new Head();

    public Head getHead1() {
        return head1;
    }

    public void setHead1(Head h) {
        this.head1 = h;
    }
    private Link link1 = new Link();

    public Link getLink1() {
        return link1;
    }

    public void setLink1(Link l) {
        this.link1 = l;
    }
    private Body body1 = new Body();

    public Body getBody1() {
        return body1;
    }

    public void setBody1(Body b) {
        this.body1 = b;
    }
    private Form form1 = new Form();

    public Form getForm1() {
        return form1;
    }

    public void setForm1(Form f) {
        this.form1 = f;
    }
    private PanelGroup groupPanel1 = new PanelGroup();

    public PanelGroup getGroupPanel1() {
        return groupPanel1;
    }

    public void setGroupPanel1(PanelGroup pg) {
        this.groupPanel1 = pg;
    }
    private TabSet tabSet1 = new TabSet();

    public TabSet getTabSet1() {
        return tabSet1;
    }

    public void setTabSet1(TabSet ts) {
        this.tabSet1 = ts;
    }
    private Tab tab1 = new Tab();

    public Tab getTab1() {
        return tab1;
    }

    public void setTab1(Tab t) {
        this.tab1 = t;
    }
    private PanelLayout layoutPanel1 = new PanelLayout();

    public PanelLayout getLayoutPanel1() {
        return layoutPanel1;
    }

    public void setLayoutPanel1(PanelLayout pl) {
        this.layoutPanel1 = pl;
    }
    private Label label1 = new Label();

    public Label getLabel1() {
        return label1;
    }

    public void setLabel1(Label l) {
        this.label1 = l;
    }
    private Label label2 = new Label();

    public Label getLabel2() {
        return label2;
    }

    public void setLabel2(Label l) {
        this.label2 = l;
    }
    private Label label3 = new Label();

    public Label getLabel3() {
        return label3;
    }

    public void setLabel3(Label l) {
        this.label3 = l;
    }
    private Label label4 = new Label();

    public Label getLabel4() {
        return label4;
    }

    public void setLabel4(Label l) {
        this.label4 = l;
    }
    private Label label5 = new Label();

    public Label getLabel5() {
        return label5;
    }

    public void setLabel5(Label l) {
        this.label5 = l;
    }
    private Label label6 = new Label();

    public Label getLabel6() {
        return label6;
    }

    public void setLabel6(Label l) {
        this.label6 = l;
    }
    private Label label7 = new Label();

    public Label getLabel7() {
        return label7;
    }

    public void setLabel7(Label l) {
        this.label7 = l;
    }
    private Label label8 = new Label();

    public Label getLabel8() {
        return label8;
    }

    public void setLabel8(Label l) {
        this.label8 = l;
    }
    private Label label9 = new Label();

    public Label getLabel9() {
        return label9;
    }

    public void setLabel9(Label l) {
        this.label9 = l;
    }
    private Label label10 = new Label();

    public Label getLabel10() {
        return label10;
    }

    public void setLabel10(Label l) {
        this.label10 = l;
    }
    private Label label11 = new Label();

    public Label getLabel11() {
        return label11;
    }

    public void setLabel11(Label l) {
        this.label11 = l;
    }
    private Label label12 = new Label();

    public Label getLabel12() {
        return label12;
    }

    public void setLabel12(Label l) {
        this.label12 = l;
    }
    private Label campoVerNombrePersona = new Label();

    public Label getCampoVerNombrePersona() {
        return campoVerNombrePersona;
    }

    public void setCampoVerNombrePersona(Label tf) {
        this.campoVerNombrePersona = tf;
    }
    private TextField campoVerTelPersona = new TextField();

    public TextField getCampoVerTelPersona() {
        return campoVerTelPersona;
    }

    public void setCampoVerTelPersona(TextField tf) {
        this.campoVerTelPersona = tf;
    }
    private TextField campoVerMailPersona = new TextField();

    public TextField getCampoVerMailPersona() {
        return campoVerMailPersona;
    }

    public void setCampoVerMailPersona(TextField tf) {
        this.campoVerMailPersona = tf;
    }
    private Label campoVerUsuario = new Label();

    public Label getCampoVerUsuario() {
        return campoVerUsuario;
    }

    public void setCampoVerUsuario(Label tf) {
        this.campoVerUsuario = tf;
    }
    private Label campoVerFechaNacimiento = new Label();

    public Label getCampoVerFechaNacimiento() {
        return campoVerFechaNacimiento;
    }

    public void setCampoVerFechaNacimiento(Label tf) {
        this.campoVerFechaNacimiento = tf;
    }
    private Label campoVerIdPersona = new Label();

    public Label getCampoVerIdPersona() {
        return campoVerIdPersona;
    }

    public void setCampoVerIdPersona(Label tf) {
        this.campoVerIdPersona = tf;
    }
    private Label campoVerFacultadPersona = new Label();

    public Label getCampoVerFacultadPersona() {
        return campoVerFacultadPersona;
    }

    public void setCampoVerFacultadPersona(Label tf) {
        this.campoVerFacultadPersona = tf;
    }
    private Label campoVerFechaIngreso = new Label();

    public Label getCampoVerFechaIngreso() {
        return campoVerFechaIngreso;
    }

    public void setCampoVerFechaIngreso(Label tf) {
        this.campoVerFechaIngreso = tf;
    }
    private Button botonIrRetirar = new Button();

    public Button getBotonIrRetirar() {
        return botonIrRetirar;
    }

    public void setBotonIrRetirar(Button b) {
        this.botonIrRetirar = b;
    }
    private Label label13 = new Label();

    public Label getLabel13() {
        return label13;
    }

    public void setLabel13(Label l) {
        this.label13 = l;
    }
    private Button botonModificar = new Button();

    public Button getBotonModificar() {
        return botonModificar;
    }

    public void setBotonModificar(Button b) {
        this.botonModificar = b;
    }
    private Button botonVolverCP2 = new Button();

    public Button getBotonVolverCP2() {
        return botonVolverCP2;
    }

    public void setBotonVolverCP2(Button b) {
        this.botonVolverCP2 = b;
    }
    

   

    public void cargarOcupacion() {
        try {
            Option[] option;
            ocupacionVO = new OcupacionesVO();
            personaBO = new PersonasBO();
            listaOcupacion = new ArrayList<OcupacionesVO>();
            String idOcupacion = "";
            String ocupacion = "";
            listaOcupacion = personaBO.llenarListaOcupacion();
            option = new Option[listaOcupacion.size()];
            
            for (int i = 0; i < listaOcupacion.size(); i++) {
                idOcupacion = listaOcupacion.get(i).getIdOcupacion();
                ocupacion = listaOcupacion.get(i).getNombreOcupacion();
                option[i] = new Option(idOcupacion, ocupacion);
            }
            optionsOcupacion.setOptions(option);
        } catch (ControlException ex) {
            Logger.getLogger(consultarPersona2.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    
    private DefaultSelectItemsArray listbox1DefaultItems1 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems1() {
        return listbox1DefaultItems1;
    }

    public void setListbox1DefaultItems1(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems1 = dsia;
    }
    private UISelectItems listbox1SelectItems = new UISelectItems();

    public UISelectItems getListbox1SelectItems() {
        return listbox1SelectItems;
    }

    public void setListbox1SelectItems(UISelectItems uisi) {
        this.listbox1SelectItems = uisi;
    }
    private DefaultSelectItemsArray listbox1DefaultItems2 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems2() {
        return listbox1DefaultItems2;
    }

    public void setListbox1DefaultItems2(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems2 = dsia;
    }
    private DefaultSelectItemsArray listbox1DefaultItems3 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems3() {
        return listbox1DefaultItems3;
    }

    public void setListbox1DefaultItems3(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems3 = dsia;
    }
    
   public void cargarInstitucion() {
        try {
            Option[] option;
            institucionVO = new InstitucionVO();
            personaBO = new PersonasBO();
            listaInstitucion = new ArrayList<InstitucionVO>();
            String idInstitucion = "";
            String institucion = "";
            listaInstitucion = personaBO.llenarListaInstitucion();
            option = new Option[listaInstitucion.size()];
            for (int i = 0; i < listaInstitucion.size(); i++) {
                idInstitucion = listaInstitucion.get(i).getIdInstitucion();
                institucion = listaInstitucion.get(i).getNombreInstitucion();
                option[i] = new Option(idInstitucion, institucion);
            }
            optionsInstitucion.setOptions(option);
        } catch (ControlException ex) {
            Logger.getLogger(consultarPersona2.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    
    private UISelectItems listbox1SelectItems1 = new UISelectItems();

    public UISelectItems getListbox1SelectItems1() {
        return listbox1SelectItems1;
    }

    public void setListbox1SelectItems1(UISelectItems uisi) {
        this.listbox1SelectItems1 = uisi;
    }
    private DefaultSelectItemsArray listbox1DefaultItems4 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems4() {
        return listbox1DefaultItems4;
    }

    public void setListbox1DefaultItems4(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems4 = dsia;
    }
    private UISelectItems listbox1SelectItems2 = new UISelectItems();

    public UISelectItems getListbox1SelectItems2() {
        return listbox1SelectItems2;
    }

    public void setListbox1SelectItems2(UISelectItems uisi) {
        this.listbox1SelectItems2 = uisi;
    }
    private DefaultSelectItemsArray listboxOcupacionDefaultItems = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListboxOcupacionDefaultItems() {
        return listboxOcupacionDefaultItems;
    }

    public void setListboxOcupacionDefaultItems(DefaultSelectItemsArray dsia) {
        this.listboxOcupacionDefaultItems = dsia;
    }
    private DefaultSelectItemsArray listboxInstitucionDefaultItems = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListboxInstitucionDefaultItems() {
        return listboxInstitucionDefaultItems;
    }

    public void setListboxInstitucionDefaultItems(DefaultSelectItemsArray dsia) {
        this.listboxInstitucionDefaultItems = dsia;
    }
    private DefaultSelectItemsArray listbox1DefaultItems5 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems5() {
        return listbox1DefaultItems5;
    }

    public void setListbox1DefaultItems5(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems5 = dsia;
    }
    private DefaultSelectItemsArray listbox1DefaultItems6 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems6() {
        return listbox1DefaultItems6;
    }

    public void setListbox1DefaultItems6(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems6 = dsia;
    }
    private DefaultSelectItemsArray dropdown1DefaultItems = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getDropdown1DefaultItems() {
        return dropdown1DefaultItems;
    }

    public void setDropdown1DefaultItems(DefaultSelectItemsArray dsia) {
        this.dropdown1DefaultItems = dsia;
    }
    private DropDown dropDownEstado = new DropDown();

    public DropDown getDropDownEstado() {
        return dropDownEstado;
    }

    public void setDropDownEstado(DropDown dd) {
        this.dropDownEstado = dd;
    }
    private SingleSelectOptionsList dropDownEstadoDefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDropDownEstadoDefaultOptions() {
        return dropDownEstadoDefaultOptions;
    }

    public void setDropDownEstadoDefaultOptions(SingleSelectOptionsList ssol) {
        this.dropDownEstadoDefaultOptions = ssol;
    }
    private Button botonEliminar = new Button();

    public Button getBotonEliminar() {
        return botonEliminar;
    }

    public void setBotonEliminar(Button b) {
        this.botonEliminar = b;
    }
    private HtmlMessages messageList1 = new HtmlMessages();

    public HtmlMessages getMessageList1() {
        return messageList1;
    }

    public void setMessageList1(HtmlMessages hm) {
        this.messageList1 = hm;
    }
    private HtmlPanelGrid gridPanelBotones = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanelBotones() {
        return gridPanelBotones;
    }

    public void setGridPanelBotones(HtmlPanelGrid hpg) {
        this.gridPanelBotones = hpg;
    }
    private Label campoVerTipoId = new Label();

    public Label getCampoVerTipoId() {
        return campoVerTipoId;
    }

    public void setCampoVerTipoId(Label campoVerTipoId) {
        this.campoVerTipoId = campoVerTipoId;
    }
    private AddRemove addRemoveList1 = new AddRemove();

    public AddRemove getAddRemoveList1() {
        return addRemoveList1;
    }

    public void setAddRemoveList1(AddRemove ar) {
        this.addRemoveList1 = ar;
    }
    /** Holds value of property availableOptions. */
    private Option[] availableOptions = null;
    /** Holds value of property selectedOptions. */
    private String[] selectedOptions = null;

    public Option[] getAvailableOptions() {
        return availableOptions;
    }

    public void setAvailableOptions(Option[] availableOptions) {
        this.availableOptions = availableOptions;
    }

    public String[] getSelectedOptions() {
        return selectedOptions;
    }

    public void setSelectedOptions(String[] selectedOptions) {
        this.selectedOptions = selectedOptions;
    }

    // </editor-fold>
    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public consultarPersona2() {
        personaVO = getRequestBean1().getPersonaVO();
        consultarPersonaEspecifica(personaVO);
    }

    /**
     * <p>Callback method that is called whenever a page is navigated to,
     * either directly via a URL, or indirectly via page navigation.
     * Customize this method to acquire resources that will be needed
     * for event handlers and lifecycle methods, whether or not this
     * page is performing post back processing.</p>
     * 
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request.  Instead, they represent the
     * property values that were saved for this view when it was rendered.</p>
     */
    @Override
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();


        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here

        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("consultarPersona2 Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
        }

    // </editor-fold>
    // Perform application initialization that must complete
    // *after* managed components are initialized
    // TODO - add your own initialization code here
    }

    /**
     * <p>Callback method that is called after the component tree has been
     * restored, but before any event processing takes place.  This method
     * will <strong>only</strong> be called on a postback request that
     * is processing a form submit.  Customize this method to allocate
     * resources that will be required in your event handlers.</p>
     */
    @Override
    public void preprocess() {
    }

    /**
     * <p>Callback method that is called just before rendering takes place.
     * This method will <strong>only</strong> be called for the page that
     * will actually be rendered (and not, for example, on a page that
     * handled a postback and then navigated to a different page).  Customize
     * this method to allocate resources that will be required for rendering
     * this page.</p>
     */
    @Override
    public void prerender() {

        rolVO = new RolVo();
        personaBO = new PersonasBO();
        List<RolVo> listaRolesDisponibles = new ArrayList<RolVo>();
        List<RolVo> listaRolesSelecionados = new ArrayList<RolVo>();
        String idRol = "";
        String nombreRol = "";

        try {
            listaRolesDisponibles = personaBO.llenarListaRoles();
            listaRolesSelecionados = personaBO.consultarRolesPersonaPk(personaVO.getIdPersona());
            Option[] opcion = new Option[listaRolesDisponibles.size()];
            String[] opcion2 = new String[listaRolesSelecionados.size()];

            for (int i = 0; i < listaRolesDisponibles.size(); i++) {
                idRol = listaRolesDisponibles.get(i).getIdRol();
                nombreRol = listaRolesDisponibles.get(i).getNombreRol();
                opcion[i] = new Option(idRol, nombreRol);
            } // end for

            for (int i = 0; i < listaRolesSelecionados.size(); i++) {
                idRol = listaRolesSelecionados.get(i).getIdRol();
                opcion2[i] = (idRol);
            }


            availableOptions = opcion;
            selectedOptions = opcion2;
        } catch (Exception e) {
            e.getStackTrace();
        }
    }

    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called (regardless of whether
     * or not this was the page that was actually rendered).  Customize this
     * method to release resources acquired in the <code>init()</code>,
     * <code>preprocess()</code>, or <code>prerender()</code> methods (or
     * acquired during execution of an event handler).</p>
     */
    @Override
    public void destroy() {
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1) getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1) getBean("SessionBean1");
    }

    public String tab1_action() {
        return null;
    }

    public void consultarPersonaEspecifica(PersonaVO personaVO) {

        personaBO = new PersonasBO();

        try {

            personaTO.setPersonaVO(personaVO);
            personaBO.consultarPersonaPk(personaTO);

            String tipoid = personaTO.getIdentificacionVO().getTipo();
            String identificacion = personaTO.getPersonaVO().getIdPersona();
            String nombrePersona = personaTO.getPersonaVO().getNombrePersona();
            Date nacimiento = personaTO.getPersonaVO().getFechaNacimiento();
            String telefono = personaTO.getPersonaVO().getTelefono();
            String email = personaTO.getPersonaVO().getEmail();
            String ocupacion = personaTO.getOcupacionVO().getNombreOcupacion();
            String institucion = personaTO.getInstitucionVO().getNombreInstitucion();
            String facultad = personaTO.getFacultadVO().getNombreFacultad();
            Date ingreso = personaTO.getPersonaVO().getFechaIngreso();
            String estado = personaTO.getPersonaVO().getEstadoActual();
            String usuario = personaTO.getPersonaVO().getUsuario();

            campoVerTipoId.setValue(tipoid);
            campoVerIdPersona.setValue(identificacion);
            campoVerNombrePersona.setValue(nombrePersona);
            campoVerFechaNacimiento.setValue(nacimiento);
            campoVerTelPersona.setValue(telefono);
            campoVerMailPersona.setValue(email);
            
            dropDownOcupacion.setValue(ocupacion);
            
            dropDownInstitucion.setValue(institucion);
            campoVerFacultadPersona.setValue(facultad);
            campoVerFechaIngreso.setValue(ingreso);
            dropDownEstado.setValue(estado);
            campoVerUsuario.setValue(usuario);


        } catch (Exception ce) {
            //error("Error al consultar los datos de la persona.");
            ce.getStackTrace();
        }
    }

    public String botonVolver_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        return "irConsultarP";
    }

    public String botonModificar_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.

        String errorM = "";

        personaBO = new PersonasBO();
        PersonaVO personaVO = new PersonaVO();

        String id = "";
        String telefono = "";
        String email = "";
        String ocupacion = "";
        String institucion = "";
        String rol = "";
        String estado = "";

        try {

            id = (String) campoVerIdPersona.getValue();
            telefono = (String) campoVerTelPersona.getValue();
            email = (String) campoVerMailPersona.getValue();
            ocupacion = (String) dropDownOcupacion.getValue();
            institucion = (String) dropDownInstitucion.getValue();
            estado = (String) dropDownEstado.getValue();



            if (id.equals("")) {
                error("Por favor ingrese el Tipo de Identificación.");
                return null;
            } else if (telefono.equals("")) {
                error("Por favor Ingrese el numero de Tléfono.");
                return null;
            } else if (email.equals("")) {
                error("Por favor ingrese el nombre de la Persona.");
                return null;
            } else if (ocupacion.equals("")) {
                error("Por favor seleccione la ocupación.");
                return null;
            } else if (institucion.equals("")) {
                error("Por favor seleccione la institución.");
                return null;
            } else if (selectedOptions.length == 0) {
                error("Por favor seleccione el rol.");
                return null;
            } else if (estado.equals("")) {
                error("Por favor ingrese el estado.");
                return null;
            }



            personaVO.setIdPersona(id);
            personaVO.setTelefono(telefono);
            personaVO.setEmail(email);
            pOcupacionVO.setIdOcupacion(ocupacion);
            personaVO.setIdInstitucion(institucion);
            pRolVO.setIdRol(rol);
            personaVO.setEstadoActual(estado);

            errorM = personaBO.actualizarPersona(personaVO, pOcupacionVO, selectedOptions);
            info(errorM);

        } catch (Exception ce) {
            error("Error al modificar la Persona");
            ce.getStackTrace();
        }
        return "irConsultarP";

    }

    public String botonEliminar_action() {

        botonVolverCP2.setVisible(false);

        String errorM = "";
        String id = "";
        PersonaVO personaVO = new PersonaVO();
        personaBO = new PersonasBO();

        try {

            id = (String) campoVerIdPersona.getValue();

            if (id.equals("")) {
                error("Por favor ingrese el Tipo de Identificación.");
                return null;
            }

            personaVO.setIdPersona(id);

            errorM = personaBO.eliminarPersona(personaVO);
            info(errorM);

        } catch (Exception ce) {
            error("Error al eliminar la Persona");
            ce.getStackTrace();
        }


        return null;
    }

    public String botonVolverCP2_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        return "irConsultarP";
    }

    public DropDown getDropDownOcupacion() {
        return dropDownOcupacion;
    }

    public void setDropDownOcupacion(DropDown dropDownOcupacion) {
        this.dropDownOcupacion = dropDownOcupacion;
    }

    public SingleSelectOptionsList getOptionsOcupacion() {
        return optionsOcupacion;
    }

    public void setOptionsOcupacion(SingleSelectOptionsList optionsOcupacion) {
        this.optionsOcupacion = optionsOcupacion;
    }

    public DropDown getDropDownInstitucion() {
        return dropDownInstitucion;
    }

    public void setDropDownInstitucion(DropDown dropDownInstitucion) {
        this.dropDownInstitucion = dropDownInstitucion;
    }

    public SingleSelectOptionsList getOptionsInstitucion() {
        return optionsInstitucion;
    }

    public void setOptionsInstitucion(SingleSelectOptionsList optionsInstitucion) {
        this.optionsInstitucion = optionsInstitucion;
    }
}

